package test.aat.pku;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class XS {

	public static void main(String[] args) {
		try{
			String url="jdbc:mysql://localhost:3306/pkuv2?user=root&password=root";
			Connection con = DriverManager.getConnection(url);
			PreparedStatement ps=con.prepareStatement("select num,pid from pku_user");
			ResultSet rs=ps.executeQuery();
			while(rs.next()){
				String num = rs.getString("num");
				String pid = rs.getString("pid");
				System.out.println(num +"  "+pid);
				picup(num, pid);
			}
			con.close();
		}catch(Exception e){
			
		}
	}
	
	public static void picup(String num,String pid) throws IOException{
		File f=new File("F:\\桌面\\xueshi\\"+num+".jpg");
		File ff=new File("F:\\桌面\\pid\\"+pid+".jpg");
		if(f.exists()){
			InputStream is=new FileInputStream(f);
			OutputStream out=new FileOutputStream(ff);
			byte[] bs=new byte[20480*5];
			int i=-1;
			while((i=is.read(bs))>0){
				out.write(bs, 0, i);
			}
			out.flush();
			is.close();
			out.close();
		}
		
	}

}
